<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择人员')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="hold-transition box box-main">
<input id="treeId" name="treeId" type="hidden"/>
<input id="treeName" name="treeName" type="hidden"/>
<div class="wrapper">
    <div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
        <label id="btnShow" title="显示搜索" style="display:none;">︾</label>
        <label id="btnHide" title="隐藏搜索">︽</label>
    </div>
    <div class="treeSearchInput" id="search">
        <label for="keyword">关键字：</label><input type="text" class="empty" id="keyword" maxlength="50">
        <button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索</button>
    </div>
    <div class="treeExpandCollapse">
        <a href="#" onclick="$.tree.expand()">展开</a> /
        <a href="#" onclick="$.tree.collapse()">折叠</a>
    </div>
    <div id="tree" class="ztree"></div>

    <th:block th:include="include :: footer"/>
    <th:block th:include="include :: layout-latest-js"/>
    <th:block th:include="include :: ztree-js"/>

    <script th:inline="javascript">

        var url = ctx + "jinpeng/treeData?type=1";
        var options = {
            url: url,
            expandLevel: 2,
            onClick: zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            $.ajax({
                async: false,
                url: "/empSalary/export",
                data: {
                    "id": treeNode.id
                },
                type: "post",
                dataType: "json",
                success: function (data) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(data.msg) + "&delete=" + true;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {

                    alert("错误,请联系管理员,错误信息:" + textStatus);
                }
            });


        }
    </script>
</div>
</body>
</html>
